<?php

include("config/config.php");

header("content-type:application/json");

try
{  
  
  $result = "";

  $dbh = new PDO("mysql:host=localhost;dbname=payment_system", 'apps', 'lcdtmlpqtrmp');
  /*** $message = a message saying we have connected ***/
  
  /*** set the error mode to excptions ***/
  $dbh->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
  
  /*** prepare the select statement ***/
  $stmt = $dbh->prepare("select servicio
                           from pa_pagos 
                          where anio = 2014");
  
  /*** bind the parameters ***/
  $stmt->bindParam(':anio', $_POST['anio'], PDO::PARAM_STR);
  
  /*** execute the prepared statement ***/
  $stmt->execute();
  
  /*** check for a result ***/
  $rows = $stmt->fetchAll();
  
  foreach ($rows as $row)
  {
    // $result = array_push_assoc($result, 'servicio', $row[0]); 
    //$result['servicio'] = $row[0];
    $aux['servicio'] = $row[0];
    $result[] = $aux;
  }
  //{
  
}
catch(Exception $e)
{
  /*** if we are here, something has gone wrong with the database ***/
  //$message = 'We are unable to process your request. Please try again later"';
  echo "Error " . $e->getMessage();
}

echo json_encode($result);

exit();

?>